package hot100;

import java.util.HashMap;
import java.util.Map;

public class findDuplicate {
    public int findDuplicate(int[] nums) {
        Map<Integer,Integer> hash = new HashMap<>();
        int ret = 0;
        for(int x : nums) {
            if(hash.getOrDefault(x,0) != 0) {
                ret = x;
                return ret;
            }
            hash.put(x,hash.getOrDefault(x,0) + 1);
        }
        return ret;
    }
}
